<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
					function cal() {
						var nums = document.getElementsByName("num");
						var result = document.getElementsByName("rs");
						var n1 = parseInt(nums[0].value);
						while (true) {
							if(n1<10){ 
								return result[0].value =n1;
							}
							if (n1 / 10 > 10) {
								n1 = n1 / 10;
								continue;
							} else {
								return result[0].value = Math.trunc(n1 / 10);
							}
						}
					}
				</script>
	</head>
	<body>
		<div align="center">
					<label for="num">输入正整数</label>
					<input type="text" name="num" value=""
						onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" /><br />
					<label>结果</label>
					<input type="text" name="rs" value="" /><br>
					<button id="btn" onclick="cal()">运算</button>
				</div>
	</body>
</html>